// 拼接url参数
let joinUrlQuery = function(query = {}) {
  let queryStr = '?';
    Object.keys(query).forEach((key, idx) => {
        let joinChar = ''
        if(idx !== Object.keys(query).length - 1) {
            joinChar = '&'
        }

        queryStr += `${key}=${query[key]}${joinChar}`
    });
    return queryStr;
}


// URL地址
let isURL = function(s) {
  return /^http[s]?:\/\/.*/.test(s)
}

// 复制文本内容
let copyTxt = function(txt) {
  wx.setClipboardData({
    data: txt,
    success: function() {
      wx.getClipboardData({
        success: function() {
          wx.showToast({
            icon: 'none',
            title: '复制成功'
          })
        }
      })
    }
  })
}

export {
  joinUrlQuery,
  isURL,
  copyTxt
}